#include <unistd.h>
#include <cstdio>
#include "Process.hpp"

Process::Process(){
  pid = 0;
  start = 0;
}

Process::Process(int i, unsigned long s){
  pid = i;
  start = s;
} 

void Process::addCall( SysCall* s){
  systemCalls.push(s);
}

int Process::getID(){
  return pid;
}

int Process::getCount(){
  return systemCalls.size();
}

int Process::stepProcess(unsigned long time){
  int e = 0;
  if((!systemCalls.empty()) && systemCalls.front()->getStart() <= time){
    //printf("%lu <= %lu\n", systemCalls.front()->getStart(), time);
    e = systemCalls.front()->runCall();// systemCalls.front()->getRetVal())
      //return e;
    printf("Replay: ran a call at %f expected: %d returned: %d.\n", (double)(time)/1000000000.0, systemCalls.front()->getRetVal(), e);
    systemCalls.pop();
  }
  return e;
}

